﻿//////////////////////////////////////////////////////////////////////////////
// <copyright file="LazyPlugin.cs" company="Venhan Technologies Pvt. Ltd.">
// (c) 2013 Venhan Technologies, Narayana Reddy Tera. All rights reserved.
// </copyright>
//////////////////////////////////////////////////////////////////////////////

namespace Venhan.Framework.PluginManagement
{
  using System;

  /// <summary>
  /// The class which deals with given plugin and its metadata.
  /// </summary>
  /// <typeparam name="TPlugin">The type of the plugin.</typeparam>
  /// <typeparam name="TPluginData">The type of the plugin data.</typeparam>
  public class LazyPlugin<TPlugin, TPluginData>
    where TPlugin : IPlugin
    where TPluginData : IPluginMetaData
  {
    #region Private Fileds

    /// <summary>
    /// The _plugin
    /// </summary>
    private Lazy<TPlugin, TPluginData> _plugin = null;

    #endregion

    #region Constructors

    /// <summary>
    /// Initializes a new instance of the <see cref="LazyPlugin{TPlugin, TPluginData}"/> class.
    /// </summary>
    /// <param name="plugin">The plugin.</param>
    public LazyPlugin(Lazy<TPlugin, TPluginData> plugin)
    {
      _plugin = plugin;
    }

    #endregion

    #region Pulic Properties

    /// <summary>
    /// Gets the plugin.
    /// </summary>
    /// <value>
    /// The plugin.
    /// </value>
    public TPlugin Plugin
    {
      get
      {
        return _plugin.Value;
      }
    }

    /// <summary>
    /// Gets the metadata.
    /// </summary>
    /// <value>
    /// The metadata.
    /// </value>
    public TPluginData Metadata
    {
      get
      {
        return _plugin.Metadata;
      }
    }

    #endregion
  }
}
